package revenge.jack_cristo.shiyuanbaoyou;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.widget.FrameLayout;
import android.widget.RadioGroup;

public class MainActivity extends AppCompatActivity {
    private Context context = this;
    private RadioGroup radioGroup;
    private FrameLayout frameLayout;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        radioGroup = (RadioGroup) findViewById(R.id.radio_group);
        frameLayout = (FrameLayout) findViewById(R.id.content_main);
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.add(R.id.content_main, new Shouye_fragment().newInstance(context));
        transaction.commit();


        radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
                switch (i) {
                    case R.id.shouye_radiobutton:
                       fragmentTransaction.replace(R.id.content_main, new Shouye_fragment().newInstance(context));
                        break;
                    case R.id.pinpai_radiobutton:
                        fragmentTransaction.replace(R.id.content_main, new Pinpai_frament().newInstance(context));
                        break;
                    case R.id.shiyuan_radiobutton:
                      fragmentTransaction.replace(R.id.content_main, new Shiyuangou_fragment().newInstance(context));
                        break;
                    case R.id.zhide_radiobutton:
                        fragmentTransaction.replace(R.id.content_main, new Zhideguang_framement().newInstance(context));
                        break;
                    case R.id.geren_radiobutton:

                        break;


                }
                fragmentTransaction.commit();

            }
        });

    }
}
